<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<script>
	$(document)
			.ready(
					function() {
						var _form = $("#scholarshipForm").validate();
						//返回
						$('#btnBack').click(function() {
							document.scholarshipForm.action = "${basePath}/scholarship/scholarshipStudentIndex";
							document.scholarshipForm.submit();
										
					  });
						//返回
						$('#btnBack2').click(function() {
							document.scholarshipForm.action = "${basePath}/scholarship/scholarshipStudentIndex";
							document.scholarshipForm.submit();
					  });
						
						//保存
						$("#btnSave")
								.click(
										function() {
											if (_form.form()) {
											 valdateRepStudentScholarship(1);
											}
										});
						//提交
						$("#btnSubmit")
								.click(
										function() {
										 layer.confirm("您是否确定提交吗?",{icon : 3,title : '提示',skin : 'layer-ext-moon'
											},function(index) {
												valdateRepStudentScholarship(2);
												 layer.close(index);
										  },function(index) {
											 layer.close(index);
											  $("#btnSubmit").attr("disabled",false);
											});	
											 
										});
					});
	    //验证学生申请奖学金是否条件
	     function valdateScholarship(param){
	     	var jxjdj=$('input[name="jxjdj"]:checked').val();
	     	if(jxjdj!=null&&jxjdj!=""){
	    		$.ajax({
	                type: "post",
	                url: "${basePath}/scholarship/valdateStudentScholarship",
	                data: { xsid :$("#stuid").val(),xnd:$("#xnd").val(),jxjdj:jxjdj},
	                success: function(data){
	             	   if(data=="1"){  //符合条件
	             		 if(param==1){  //修改
	             			document.scholarshipForm.action = "${basePath}/scholarship/modiftyStudentScholarship";
							document.scholarshipForm.submit();	 
	             		 }else if(param==2){ //提交
	             			/*var link = document.getElementById("btnSubmit");
	             			 link.style.disabled = true;*/
	             			 $("#btnSubmit").attr("disabled",true);
	             			document.scholarshipForm.action = "${basePath}/scholarship/submitStudentScholarship";
							document.scholarshipForm.submit();	 	 
	             		 }
	       		      }else{ //不符合条件
	       		     	 if(data=="21"){
	        		    		layer.alert("你不符合一等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
	        		    	    return false;
	        		    	 }else if(data=="22"){
	        		    		layer.alert("你不符合二等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
	        		    	    return false;	 
	        		    	 }else if(data=="23"){
	        		    	  layer.alert("你不符合三等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
	         		       return false; 
	        		    	 }else{
	         		       layer.alert("服务器异常", {icon: 6});
	          		       return false;	  
	         		      }      
	        		      }      
	                }
	   	   		}); 	
	     	}else{
	     		  layer.alert("请选择奖学金等级", {icon: 6});
	     	  //$("#msg01").html("请选择奖学金等级信息");
	     	  return false;
	     	}
	     }
	  function valdateRepStudentScholarship(param){
			$.ajax({
                type: "post",
                url: "${basePath}/scholarship/valdateRepStudentScholarship",
                data: { xsid :$("#stuid").val(),xnd:$("#xnd").val(),sqid :$("#sqid").val()},
                success: function(data){
             	   if(data=="1"){  //重复
             		   layer.alert("你已经申报过奖学金信息", {icon: 6});
          		       return false;
             	   }else if(data=="0"){
             		 if(param==1){  //修改
             			valdateScholarship(1);
             		 }else if(param==2){ //提交
             			valdateScholarship(2);	 
             		 }
             	   }else{
          			  layer.alert("服务器异常", {icon: 6});
        		       return false;	 
        		 }
       		       
                }
   	   		});  
	  }
</script>
</head>
<body onload="javascript:viewOrEdit();" style="height: 100%">
	<form action="#" id="scholarshipForm" name="scholarshipForm">
		 <input
			type="hidden" id="sqid" name="sqid" value="${scholarshipApply.sqid}" />
		<div id="view">
			<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="95%">
			<tr>
				<td class="table-header" colspan="6">奖学金申请表</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%;">姓名：</td>
				<td class="table-contentTD" style="width: 21%">${student.xm}</td>
				<td class="table-titleTD"  style="width: 12%">学号：</td>
				<td class="table-contentTD" style="width: 21%">${student.xh}</td>
				<td class="table-titleTD" style="width: 12%">性别：</td>
				<td class="table-contentTD" style="width: 22%">${student.xb}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">班级：</td>
				<td class="table-contentTD" style="width: 22%">${student.bjmc}</td>
				<td class="table-titleTD" style="width: 12%">专业：</td>
				<td class="table-contentTD" style="width: 22%">${student.zymc}</td>
				<td class="table-titleTD" style="width: 12%">年级：</td>
				<td class="table-contentTD" style="width: 22%">${student.njmc}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">民族：</td>
				<td class="table-contentTD" style="width: 22%">
				        ${scholarshipApply.mz}</td>
				<td class="table-titleTD" style="width: 12%">身份证件号码：</td>
				<td class="table-contentTD" style="width: 22%">${student.sfzh}</td>
				<td class="table-titleTD" style="width: 12%">出身日期：</td>
				<td class="table-contentTD" style="width: 22%"><fmt:formatDate value="${student.csrq}" pattern="yyyy-MM-dd"/></td>
			</tr>
			 <tr>
			 <td class="table-titleTD" style="width: 12%">政治面貌：</td>
				<td class="table-contentTD" style="width: 22%">
						 ${scholarshipApply.zzmm}</td>
				<td class="table-titleTD" style="width: 12%">家庭地址：</td>
				<td class="table-contentTD" style="width: 22%">${scholarshipApply.jtdz}</td>
				<td class="table-titleTD" style="width: 12%">邮政编码：</td>
				<td class="table-contentTD" style="width: 22%">${scholarshipApply.yzbm}</td>
			 </tr>
				<tr>
				<td class="table-titleTD" style="width: 12%">学年：</td>
				<td class="table-contentTD" style="width: 22%">
					${scholarshipApply.xnd}</td>
				<td class="table-titleTD" style="width: 12%">奖学金等级：</td>
				<td class="table-contentTD" style="width: 22%">
				  <input type="radio"  value="1"  disabled="disabled" <c:if test="${scholarshipApply.jxjdj==1}">checked="checked"</c:if>/>1
				  <input type="radio"  value="2"  disabled="disabled" <c:if test="${scholarshipApply.jxjdj==2}">checked="checked"</c:if>/>2
				  <input type="radio"  value="3"  disabled="disabled" <c:if test="${scholarshipApply.jxjdj==3}">checked="checked"</c:if>/>3
				<%--  <c:choose>
				  <c:when test="${scholarshipApply.jxjdj==1}">
				  <input type="radio" value="1" disabled="disabled" checked="checked"/>1&nbsp;&nbsp;<input type="radio" value="2" disabled="disabled"/>2&nbsp;&nbsp;<input type="radio"  value="3" disabled="disabled"/>3
				  </c:when>
				   <c:when test="${scholarshipApply.jxjdj==2}">
				  <input type="radio" value="1"/>1&nbsp;&nbsp;<input type="radio"  value="2" disabled="disabled" checked="checked" disabled="disabled"/>2&nbsp;&nbsp;<input type="radio"  value="3" disabled="disabled"/>3
				  </c:when>
				   <c:when test="${scholarshipApply.jxjdj==3}">
				  <input type="radio"  value="1" disabled="disabled" checked="checked"/>1&nbsp;&nbsp;<input type="radio"  value="2" disabled="disabled"/>2&nbsp;&nbsp;<input type="radio"  value="3" disabled="disabled" checked="checked"/>3
				  </c:when>
				  <c:otherwise>
				  <input type="radio"  value="1" disabled="disabled"/>1&nbsp;&nbsp;<input type="radio"  value="2" disabled="disabled"/>2&nbsp;&nbsp;<input type="radio"  value="3"/>3
				  </c:otherwise>
				 </c:choose> --%>
				</td>
				<td class="table-titleTD" style="width: 12%">状态：</td>
				<td class="table-contentTD" style="width: 22%">
				 <c:choose>
				 <c:when test="${scholarshipApply.states==0}">
				  未提交				 
				 </c:when>
				<c:when test="${scholarshipApply.states==1}">
				审核退回			 
				 </c:when>
				 <c:when test="${scholarshipApply.states==2}">
				审核中			 
				 </c:when>
				<c:when test="${scholarshipApply.states==3}">
				审核通过			 
				 </c:when>
				<c:when test="${scholarshipApply.states==8}">
				退回并结束		 
				 </c:when>
				<c:when test="${scholarshipApply.states==9}">
				撤回	 
				 </c:when>
				 </c:choose>
				</td>
			</tr>
			<tr>
			<td class="table-titleTD">家庭成员：</td>
			<td colspan="5">
			<%@ include file="/module/studentFamily.jsp"%>
			</td>
			</tr>
		  <tr>
		  <td class="table-titleTD" style="width: 12%">第一学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade1}</td>
		  <td class="table-titleTD" style="width: 12%">第二学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade2}</td>
		  <td class="table-titleTD" style="width: 12%"></td>
		  <td class="table-contentTD" style="width: 22%"></td>
		  </tr>
		  <tr>
		  <td class="table-titleTD">学年学习情况：</td>
		  <td colspan="5">
		  <%@ include file="/module/studentCourse.jsp"%>
		  </td>
		  </tr>
			<tr>
			<td class="table-titleTD">获奖情况：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  style="width: 90%;height: 80px;" disabled="disabled">${scholarshipApply.hjqk}</textarea>
			</td>
			</tr>
			<tr>
			<td class="table-titleTD"></td>
			<td colspan="5" class="table-contentTD">
			<textarea  style="width: 90%;height: 80px;" disabled="disabled">${scholarshipApply.sqly}</textarea>
			</td>
			</tr>
		</table>
		<br/>
		<c:if test="${scholarshipApply.states!=0}">
		<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="95%">
			<tr>
				<td class="table-header" colspan="6">审批结果</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="text-align: center;">序号</td>
				<td class="table-titleTD" style="text-align: center;">审批人</td>
				<td class="table-titleTD"  style="text-align: center;">审批步骤</td>
				<td class="table-titleTD" style="text-align: center;">审批结果</td>
				<td class="table-titleTD" style="text-align: center;">审批时间</td>
				<td class="table-titleTD" style="text-align: center;">审批意见</td>
			</tr>
			<c:forEach items="${chekResultList}" var="res" varStatus="status">
			<tr>
				<td class="table-contentTD" style="text-align: center;">${status.index+1}</td>
				<td class="table-contentTD" style="text-align: center;">${res.userName}</td>
				<td class="table-contentTD"  style="text-align: center;">${res.stepName}</td>
				<td class="table-contentTD" style="text-align: center;">${res.userState}</td>
				<td class="table-contentTD" style="text-align: center;">${res.approvalTime}</td>
				<td class="table-contentTD" style="text-align: center;">${res.comments}</td>
			</tr>
			</c:forEach>
			</table>
		</c:if>
		</div>
		<div id="edit" style="display: none;">
			<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="95%">
			<tr>
				<td class="table-header" colspan="6">奖学金申请表</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%;"><font color="red">*</font>姓名：</td>
				<td class="table-contentTD" style="width: 21%">${student.xm}<input type="hidden" id="stuid" name="stuid" value="${student.xsid}"/></td>
				<td class="table-titleTD"  style="width: 12%">学号：</td>
				<td class="table-contentTD" style="width: 21%">${student.xh}</td>
				<td class="table-titleTD" style="width: 12%">性别：</td>
				<td class="table-contentTD" style="width: 22%">${student.xb}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">班级：</td>
				<td class="table-contentTD" style="width: 22%">${student.bjmc}<input type="hidden" id="bjid" name="bjid" value="${student.bjid}"/></td>
				<td class="table-titleTD" style="width: 12%">专业：</td>
				<td class="table-contentTD" style="width: 22%">${student.zymc}</td>
				<td class="table-titleTD" style="width: 12%">年级：</td>
				<td class="table-contentTD" style="width: 22%">${student.njmc}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>民族：</td>
				<td class="table-contentTD" style="width: 22%"><select id="mz" name="mz" class="required selectList" placeholder="请选择民族">
						<option value="">请选择</option>
							<c:forEach items="${nationList}" var="nation">
								<option value="${nation.codename}">${nation.codename}</option>
							</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">身份证件号码：</td>
				<td class="table-contentTD" style="width: 22%">${student.sfzh}</td>
				<td class="table-titleTD" style="width: 12%">出身日期：</td>
				<td class="table-contentTD" style="width: 22%"><fmt:formatDate value="${student.csrq}" pattern="yyyy-MM-dd"/></td>
			</tr>
			 <tr>
			 <td class="table-titleTD" style="width: 12%"><font color="red">*</font>政治面貌：</td>
				<td class="table-contentTD" style="width: 22%"><select id="zzmm" name="zzmm" class="required selectList" placeholder="请选择政面貌">
						<option value="">请选择</option>
							<c:forEach items="${sysCodeList}" var="code">
								<option value="${code.codename}">${code.codename}</option>
							</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">家庭地址：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="jtdz" name="jtdz" class="inputText" autocomplete="off" value="${student.jtdz}"></td>
				<td class="table-titleTD" style="width: 12%">邮政编码：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="yzbm" name="yzbm" class="inputText" autocomplete="off" value="${student.yzbm}"/></td>
			 </tr>
				<tr>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>学年：</td>
				<td class="table-contentTD" style="width: 22%"><select id="xnd" name="xnd" class="required selectList" placeholder="请选择学年" onchange="javascript:getRecommendStudentScore(this.value);">
					<option value="">请选择</option>
					<c:forEach items="${yearList}" var="y">
						<option value="${y.xnd}">${y.xnd}</option>
					</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>奖学金等级：</td>
				 <td class="table-contentTD" style="width: 22%" colspan="3">
				 <input type="radio" id="jxjdj" name="jxjdj"  value="1"  <c:if test="${scholarshipApply.jxjdj==1}">checked="checked"</c:if>/>1
				  <input type="radio"  id="jxjdj" name="jxjdj" value="2"  <c:if test="${scholarshipApply.jxjdj==2}">checked="checked"</c:if>/>2
				  <input type="radio" id="jxjdj" name="jxjdj"  value="3"  <c:if test="${scholarshipApply.jxjdj==3}">checked="checked"</c:if>/>3
				<%--  <c:choose>
				  <c:when test="${scholarshipApply.jxjdj==1}">
				  <input type="radio" id="jxjdj" name="jxjdj" value="1"  checked="checked"/>1&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="2"/>2&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="3"/>3
				  </c:when>
				   <c:when test="${scholarshipApply.jxjdj==2}">
				  <input type="radio" id="jxjdj" name="jxjdj" value="1"/>1&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="2"  checked="checked"/>2&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="3"/>3
				  </c:when>
				   <c:when test="${scholarshipApply.jxjdj==3}">
				  <input type="radio" id="jxjdj" name="jxjdj" value="1" disabled="disabled" checked="checked"/>1&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="2"/>2&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="3"  checked="checked"/>3
				  </c:when>
				  <c:otherwise>
				  <input type="radio" id="jxjdj" name="jxjdj" value="1"/>1&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="2"/>2&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="3"/>3
				  </c:otherwise>
				 </c:choose> --%>
				</td>
			</tr>
			<tr>
			<td class="table-titleTD">家庭成员：</td>
			<td colspan="5">
			<%@ include file="/module/studentFamily.jsp"%>
			</td>
			</tr>
		  <tr>
		  <td class="table-titleTD" style="width: 12%">第一学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade1}</td>
		  <td class="table-titleTD" style="width: 12%">第二学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade2}</td>
		  <td class="table-titleTD" style="width: 12%"></td>
		  <td class="table-contentTD" style="width: 22%"></td>
		  </tr>
		  <tr>
		  <td class="table-titleTD">学年学习情况：</td>
		  <td colspan="5" id="table_course">
		  <%@ include file="/module/studentCourse.jsp"%>
		  </td>
		  </tr>
			<tr>
			<td class="table-titleTD"><font color="red">*</font>获奖情况：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="hjqk" name="hjqk" style="width: 90%;height: 80px;" placeholder="请输入获奖情况" class="required">${scholarshipApply.hjqk}</textarea>
			</td>
			</tr>
			<tr>
			<td class="table-titleTD"><font color="red">*</font>申请理由：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="sqly" name="sqly" style="width: 90%;height: 80px;" placeholder="请输入申请理由"  class="required">${scholarshipApply.sqly}</textarea>
			</td>
			</tr>
		</table>
		</div>
		<br />
		<div id="button-view">
			<table cellpadding="1" cellspacing="1" border="0" align="left">
				<tr>
				<c:if test="${scholarshipApply.states==0 or scholarshipApply.states==1}">
				<td><input type="button" id="btnSubmit" autocomplete="off"  class="inputButton" style="text-align: center;" value="提交"/></td>
					<%-- 			<kl:permission permisstionList="${permisstionList}" --%>
					<%-- 						currentUser="${_login_console_user}" --%>
					<%-- 						currentCatalogId="<%=CatalogUtils.getCatalogId("catalog0")%>" key="modify"> --%>
					<td><input type="button" id="btnEdit" autocomplete="off"  class="inputButton"
						style="text-align: center;" value="修改"
						onclick="javascript:gotoEditPage();" /></td>
				  </c:if>
					<%-- 		   </kl:permission> --%>
					<td><input type="button" id="btnBack" autocomplete="off"  class="inputButton"
						value="返回" style="text-align: center;" /></td>
				</tr>
			</table>
		</div>
		<div id="button-edit">
			<table cellpadding="1" cellspacing="1" border="0" align="left">
				<tr>
					<td><input type="button" id="btnSave" autocomplete="off"  class="inputButton"
						style="text-align: center;" value="保存" /></td>
					<td><input type="button" id="cancelSave" autocomplete="off"  class="inputButton"
						style="text-align: center;" value="取消"
						onclick="javascript:gotoViewPage();" /></td>
					<td><input type="button" id="btnBack2" autocomplete="off"  class="inputButton"
						value="返回" style="text-align: center;" /></td>
				</tr>
			</table>
		</div>
	</form>
</body>
<script type="text/javascript">
compareListValue(document.getElementById('mz'),'${scholarshipApply.mz}');
compareListValue(document.getElementById('xnd'),'${scholarshipApply.xnd}');
compareListValue(document.getElementById('zzmm'),'${scholarshipApply.zzmm}');
	 if("${msg}"!=""){
	       layer.alert("${msg}", {icon: 6});
	 }
</script>
</html>
